'use strict'
const express = require('express')
const router = express.Router()
const capi = require('../util/capiConfig')
// 查看实例列表
router.get('/region', (req, res) => {
  // 传入配置以覆盖默认项
  capi.request({
    Region: 'bj',
    Action: 'DescribeInstances',
    otherParam: 'otherParam'
  }, {
    serviceType: 'cvm'
  }, (error, data) => {
    if (error) {
      res.json(error)
      return false
    } else {
      res.json(data)
    }
  })
})
router.get('/zone', (req, res) => {
  capi.request(
    {
      Region: 'bj',
      Action: 'DescribeZones',
      otherParam: 'otherParam'
    },
    {
      serviceType: 'cvm'
    },
    (error, data) => {
      if (error) {
        res.json(error)
        return false
      } else {
        res.json(data)
      }
    }
  )
})
module.exports = router
